if(!styleObj){
	var styleObj = {};
}

$.extend(styleObj,{
	urlMap:{
		 searchStyle:"../style/list.do"
		,servlet:"../StyleServlet"
	}
	,trTemplate:function(data,index,container){
		var html = '<input type="radio" id="styleDiv'+index
			+'" name="styleRadio" value="'+data+'" onclick="styleObj.radioClick()"/><label for="styleDiv'+index+'">'+data+'</label>';
		return html;
	}
	,radioClick:function(){
		var name = $(":radio[name=styleRadio]:checked").val();
		$("#testFrame").attr("src","styleTestInframe.jsp?name=" + name);
	}
	,search:function(){
		commonUtil.jsonPost(styleObj.urlMap["searchStyle"],{},function(data){
			$("#styleDivParent").empty().html('<div id="styleDiv"></div>');
			commonUtil.generateDataTable(data.styleList,"styleDiv",styleObj.trTemplate);
			$.each($(":radio[name=styleRadio]"),function(i,n){
				if(n.value==data.style){
					$(n).attr("checked","checked");
					return;
				}
			});
			$("#styleDiv").buttonset();
		},"#styleDivParent");
	}
	,changeStyle:function(){
		var checkedStyle = $(":radio[name=styleRadio]:checked").val();
		commonUtil.jsonPost(styleObj.urlMap["servlet"],{"changeStyle":checkedStyle},function(data){
			window.location="main.jsp?tab=5";
		});
	}
	,refreshStyle:function(){
		commonUtil.jsonPost(styleObj.urlMap["servlet"],{},function(data){
			styleObj.search();
		});
	}
});

$(document).ready(function(){
	styleObj.search();
	$("button").button();
});
